Skip to content

feat: add explicit json apply actions - #38

Merged
jinbagi merged 1 commit into
masterfrom
codex/form-json-sync-ux
Jul 3, 2026
Merged

feat: add explicit json apply actions#38
jinbagi merged 1 commit into
masterfrom
codex/form-json-sync-ux

Conversation

@jinbagi

@jinbagi jinbagi commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add an explicit Apply to Visual Editor action for Payload JSON drafts.
  • Add an explicit Apply to Fields action for Plugin JSON drafts.
  • Document the same-draft JSON apply pattern and extend E2E coverage for the synced draft flow.

Verification

  • corepack pnpm exec tsc -b --pretty false
  • corepack pnpm lint
  • corepack pnpm build
  • E2E_TARGET_URL=http://127.0.0.1:55173/ui/ playwright test e2e/tests/resource-required-templates.spec.ts --reporter=list --workers=1

Copilot AI review requested due to automatic review settings July 3, 2026 18:44
@jinbagi
jinbagi merged commit bd0cd34 into master Jul 3, 2026
@jinbagi
jinbagi deleted the codex/form-json-sync-ux branch July 3, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds explicit “apply” actions to same-draft JSON editors so users can intentionally sync valid JSON edits into the paired visual/fields editor, and updates documentation and E2E coverage to reflect the standardized flow.

Changes:

  • Add “Apply to Visual Editor” for Payload JSON drafts in FormJsonTabs.
  • Add “Apply to Fields” for Plugin JSON drafts in the plugin editor drawer.
  • Extend Playwright E2E coverage and document the same-draft apply pattern.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/components/form/FormJsonTabs.tsx Introduces applyJsonToForm + explicit “Apply to Visual Editor” action and reuses it during tab switching.
src/components/form-slice/FormItemPlugins/PluginEditorDrawer.tsx Introduces applyJsonToFields + explicit “Apply to Fields” action and reuses it during tab switching.
e2e/tests/resource-required-templates.spec.ts Adds assertions that form edits propagate to JSON drafts and that “apply” actions switch back to the paired editor.
docs/design/json-editor-standard.md Documents the explicit apply action standard for same-draft JSON editors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +415 to +427
const applyJsonToForm = useCallback(() => {
try {
const parsed = JSON.parse(jsonStr || '{}') as Record<string, unknown>;
const sanitizedParsed = rawData ? stripSystemReadonlyFields(parsed) : parsed;
form.reset(sanitizedParsed, { keepDefaultValues: true });
setJsonTabDirty(false);
setJsonError(null);
void form.trigger();
return true;
} catch (e) {
setJsonError('Invalid JSON: ' + String(e));
return false;
}

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 913aed1c31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

try {
const parsed = JSON.parse(jsonStr || '{}') as Record<string, unknown>;
const sanitizedParsed = rawData ? stripSystemReadonlyFields(parsed) : parsed;
form.reset(sanitizedParsed, { keepDefaultValues: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve applied JSON when reopening Payload JSON

In create flows that pass a createJsonTemplate (routes, services, upstreams), this reset() clears formState.touchedFields. After a user edits Payload JSON, clicks the new Apply button, and then opens Payload JSON again without touching a visual field, handleTabChange still treats the form as untouched and rewrites jsonStr from the minimal template, discarding the JSON payload they just applied. Mark the form as no longer template-initial or preserve touched state after applying JSON so the next JSON tab render serializes form.getValues() instead of the template.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants